﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AvansRS.Domain.DataInterface;
using StructureMap.Pipeline;
using StructureMap;
using System.Reflection;

namespace AvansRS.Data.InsertBuilders
{
    class Insert<T>
    {
        protected T Instance { get; set; }

        protected Insert(T instance)
        {
            Instance = instance;
        }

        private T Build()
        {
            IRepository<T> repository = ObjectFactory.GetInstance<IRepository<T>>();
            repository.Add(Instance);
            return Instance;
        }

        public static implicit operator T(Insert<T> insert)
        {
            return insert.Build();
        }
    }
}
